package com.example.dubbo.storage.core.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.UUID;

/**
 * Shang
 * 2020/10/26 22:56
 */
public class IdUtil {

    public static String generateUUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    public static String generateBizId() {
        return JodaTimeUtil.format(new Date(), JodaTimeUtil.MILLS_NUMBER_FORMAT) + generateSimpleUUID();
    }

    public static String generateSimpleUUID() {
        return StringUtils.left(generateUUID(), 5);
    }

    /**
     * 生成6位短信验证码
     */
    public static String generateSmsCode() {
        return StringUtils.left(Math.abs(UUID.randomUUID().toString().hashCode()) + "000000", 6);
    }

    public static void main(String[] args) {
        System.out.println(generateBizId());
    }
}
